/** 
 * Project Name:Food_Sysrem 
 * File Name:Get_user_by_id.java 
 * Package Name:priv.web.control 
 * Date:2018年5月30日下午11:18:20 
 * Copyright (c) 2018, Fkuennh All Rights Reserved. 
 * 
*/  
  
package priv.web.control;  
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSON;

import priv.web.util.ReviewJDBCUtil;

public class Get_User_By_Id extends HttpServlet{
	private static final Logger logger = Logger.getLogger(Get_User_By_Id.class);
//	用于查询单条信息，以做修改操作	
		@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String sql = "select * from food_users where b_id=?";
		try {
			List<Map<String, Object>> query = ReviewJDBCUtil.query(sql,req.getParameter("user_id"));
			resp.setContentType("application/json;charset=utf-8");
			if(query.size()>0){
				resp.getWriter().print(JSON.toJSONString(new Package(1, "OK", query.get(0))));
			}else{
				resp.getWriter().print(JSON.toJSONString(new Package(0, "Please Check if your ID is right", null)));
			}
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
			logger.error(e);
		}
	}
	
	
	
}
  